#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <set>

using namespace std;

void getAnagram(vector<string> &words, map<string, vector<string> > &myMap)
{
    for (int i = 0; i < words.size(); i++) {
        string word = words[i];
        sort(word.begin(), word.end());
        myMap[word].push_back(words[i]);
    }
}

int main(int argc, char **argv)
{
    vector<string> words;
    words.push_back("cat");
    words.push_back("tac");
    words.push_back("hkuang");
    words.push_back("hkuangk");
    words.push_back("hgnauk");
    words.push_back("miller");
    words.push_back("merll");
    words.push_back("mlerli");
    words.push_back("mierll");
    map<string, vector<string> > myMap;
    getAnagram(words, myMap);
    for (map<string, vector<string> >::iterator iter = myMap.begin(); iter != myMap.end(); iter++) {
        cout << iter->first << " : ";
        for (int i = 0; i < iter->second.size(); i++) {
            cout << iter->second[i] << " ";
        }
        cout << endl;
    }
    cout << "-----------------Test 1--------------------" << endl;


    cout << "-----------------Test 2--------------------" << endl;


    cout << "-----------------Test 3--------------------" << endl;


    cout << "-----------------Test 4--------------------" << endl;


    cout << "-----------------Test 5--------------------" << endl;



}
